home *** CD-ROM | disk | FTP | other *** search
- LISTING 12 - Illustrates default arguments
-
- // minutes.cpp
-
- #include <iostream.h>
-
- inline int minutes(int hrs, int mins = 0)
- {
- return hrs * 60 + mins;
- }
-
- main()
- {
- cout << "3 hrs == " << minutes(3) << " minutes" << endl;
- cout << "3 hrs, 26 min == " << minutes(3,26) << " minutes" <<
- endl;
- return 0;
- }
-
- // Output:
- 3 hrs == 180 minutes
- 3 hrs, 26 min == 206 minutes
-
-